package corej.course.net;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UDPServer {
    public static void main(String[] args) throws Exception {
        DatagramSocket ds = new DatagramSocket(10000);
        while (true) {
            byte[] bs = new byte[100];
            DatagramPacket receiveLetter = new DatagramPacket(bs, 0, bs.length);
            ds.receive(receiveLetter);

            InetAddress address = receiveLetter.getAddress();
            int port = receiveLetter.getPort();

            String text = "Hello World";
            byte[] bs2 = text.getBytes();
            DatagramPacket sendLetter = new DatagramPacket(bs2, 0, bs2.length,
                    address, port);
            ds.send(sendLetter);
        }

    }

}
